// init
import {init} from '../../util/app';
// plugins
import createLoading from 'dva-loading';
import createEffectLock from '../../plugin/effectLock';
import {createWebLocalStore, getWebState} from '../../plugin/webLocalStore';
import {createLoginSession} from '../../plugin/loginSession';
// models
import home from './model/home';
import store from './model/store';
import bookcase from './model/bookcase';
import me from './model/me';
import banner from './model/banner';
// router
import router from './router';
// css
import './index.css';

const APP_WEB_STATE = 'WEB_STATE_CHILDREN_READER';

let initialState = getWebState(APP_WEB_STATE) || {
    login: {
    	channel: 'a3384a9ca39efb36822d0b10b62fbd6c',
		loginRedirect: '/',
		logoutRedirect: '/'
    }
};
// 重置插件属性
if(initialState.loading) delete initialState.loading;// 重置loading
if(initialState.effectLock) delete initialState.effectLock;// 重置effectlock

const dvaApp = init({
    initialState: initialState,
    plugins: [
        createWebLocalStore(APP_WEB_STATE),
        createLoginSession(),
        createLoading(),
        createEffectLock()
    ],
    models: [
    	home,
    	store,
    	bookcase,
    	me,
    	banner
    ],
    router: router,
    start: '#root'
});